package org.example;

/**
 * @ClassName RandomPrize
 * @Description
 * @Author zhangsw
 * @Date 2021/1/30 22:57
 * @Version 1.0
 */
public class RandomPrize {
    public static void main(String[] args) {
        for (int i = 0; i < 1000; i++) {
            String randomBeanId = getRandomBeanId();
            System.err.println(randomBeanId);
        }
    }
    /**
     * 固定概率获取beanId
     * @return
     */
    public static String getRandomBeanId() {
        String prizeId = "";
        //优酷周卡  30%
        String ykZkId = "521";
        //5元权益金 30%
        String yqj5yId = "5916";
        //60兆流量  18%
        String ll60zId = "5687";
        //爱奇艺月卡 10%
        String aqyykId = "5822";
        //优酷月卡 10%
        String ykykId = "561";
        //优酷年卡 1%
        String ykNkId = "564";
        //电信PLUS会员 1%
        String dxPlusId = "5236";
        Integer number = randomNumber();
        if (number >=1 && number <= 300) {//优酷周卡  30%
            prizeId = ykZkId;
        }
        if (number >= 301 && number <= 600) {//5元权益金 30%
            prizeId = yqj5yId;
        }
        if (number >= 601 && number <= 780) {//60兆流量  18%
            prizeId = ll60zId;
        }
        if (number >= 781 && number <= 880) { //爱奇艺月卡 10%
            prizeId = aqyykId;
        }
        if (number >= 881 && number <= 980) {//优酷月卡 10%
            prizeId = ykykId;
        }
        if (number >= 981 && number <= 990) {//优酷年卡 1%
            prizeId = ykNkId;
        }
        if (number >= 991 && number <= 1000) {//电信PLUS会员 1%
            prizeId = dxPlusId;
        }
        return prizeId;
    }

    private static Integer randomNumber() {
        return (int) (Math.random() * 1000 + 1);
    }
}
